import { BattleResult } from "js/typeDefine/typeDefine"

class ArenaHandle {
    arenaScoreBaseTime: 5
    arenaScoreMax: 5000

    getArenaPointMax() {
        return this.arenaScoreMax
    }

    getBattlePoint(score1, score2, result) {
        let coe = result == BattleResult.Win ? 1 : -1
        let addPoint1, addPoint2
        if (score1 > score2) {
            let diffPer = (score1 - score2) / 30
            addPoint1 = (diffPer > 1 ? 5 : Math.floor(30 * (1 - diffPer)) + 5) * coe
        } else {
            let diffPer = (score2 - score1) / 50
            addPoint1 = (diffPer > 1 ? 15 : Math.floor(15 * diffPer) + 5) * coe
        }
        if (Math.abs(addPoint1) > 20) {
            addPoint1 = 20 * coe
        }
        addPoint2 = (Math.floor(addPoint1 * Math.random()) + 5) * coe * -1
        return { addPoint1: addPoint1, addPoint2: addPoint2 }
    }

    // async start(team1, team2, seed) {
    //     let battleHandle = new BattleHandle(seed)
    //     battleHandle.initTeam(team1, team2);
    //     battleHandle.isAnimate = false
    //     await battleHandle.teamAppear();
    //     battleHandle.setBattleTimeout(0)
    //     let battleData = await battleHandle.start();
    //     battleHandle.clearBattleAllTimer()
    //     return { result: battleData.result || BattleResult.Lost }
    // }
     
}


let arenaHandle = new ArenaHandle()
export default arenaHandle